<%@ include file="/WEB-INF/views/taglib.jsp" %>
<h3>Fault Code Form</h3>	
	<form:form id="form" method="post" modelAttribute="systemCodeForm"  cssClass="simpleForm" onsubmit="formSubmit()" >
		<form:hidden path="systemCodeType.systemCodeTypeId" />
		<jsp:include page="/WEB-INF/views/message.jsp"></jsp:include>
	  	<fieldset>
	  		<legend>Fault Code Info</legend>
	  		<aims:column cssErrorClass="error" path="systemCode">
	  		<form:label path="systemCode">
	  			Fault Code *
	 		</form:label>
	 		<spring:url value="/systemCode/faultCode?id=" var="faultCodeUrl" />
	 		<form:select path="systemCode" id="systemCode" onchange="location.href='${faultCodeUrl}'+this.value">
	 			<form:option value=""></form:option>
	 			<form:options items="${globalFaultCode}" itemValue="systemCode1" itemLabel="systemCodeValueDescription" />
	 		</form:select> <form:errors path="systemCode" cssClass="errorSimple"  />   
	  		</aims:column>
	  		
			<aims:column cssErrorClass="error" path="selSystemCodeValue" >
			<form:label path="systemCodeValue">
	  			Asset Model * 
	 		</form:label>
	 		<form:select path="systemCodeValue" size="18" multiple="multiple" cssStyle="width:200px">
	  			<form:options items="${assetModels}" itemValue="assetModelCode" itemLabel="assetModelCode" />
	  		</form:select>
	  		<a onclick="moveElements(systemCodeValue,selSystemCodeValue)">>></a> 
	  		<a onclick="moveElements(selSystemCodeValue,systemCodeValue)"><<</a>
	  		
	  		<form:select path="selSystemCodeValue" size="18" multiple="multiple" cssStyle="width:200px">
	  			<form:options items="${systemCodeValues}" itemValue="systemCode2" itemLabel="systemCode2" />
	  		</form:select>
	  		<form:errors path="selSystemCodeValue"  cssClass="errorSimple" />
			</aims:column>
			</fieldset>
      <div class="action">
			<button type="submit"  class="button positive">
				Update
			</button>
	 </div>	
	</form:form>
	<script type="text/javascript">
		$(document).ready(function() {
			if($('#selSystemCodeValue option').length > 0)
			{
				$('#selSystemCodeValue option').each(
				function() {
					$('#systemCodeValue option[value="'+$(this).val()+'"]').remove();
					
				});	
			}
		});
		
		function formSubmit()
		{
			if($('#selSystemCodeValue option').length > 0) {
				$('#selSystemCodeValue option').each(
				  function() {
				   	$(this).attr('selected','selected'); 
				  }
				);
			}
		}
	</script>